<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>节流</title>
  <script src="./node_modules/lodash/lodash.js"></script>
</head>
<body>
    <button>点我数字+1</button>
    <span></span>
<script type='text/javascript'>
    let button = document.querySelector('button')
    let span = document.querySelector('span')
    let count = 0
    // throttle单词学到了，节流阀
    button.onclick = _.throttle(()=>{
        count++
        span.innerText = count
        console.log('节流函数执行了');
    },5000)
    /**
     * 和防抖的区别：在于是否和用户操作的频率有关
     * 防抖：其实是减少执行次数
     * 节流：其实就是降低执行的频率，原本频率完全按照用户的来，现在按照管控规定的来
     * */ 
</script>
</body>
</html>